#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
int main()
{
    FILE *orig = fopen("./test.file.orig", "w");
    if (orig == NULL)
    {
        perror("open failed!\n");
        exit(-1);
    }
    // 写入内容
    fprintf(orig, "1234");
    printf("write 1234 to file test.file.orig...\n");
    fclose(orig);
    //打开另一个文件读
    FILE *link = fopen("./test.file.link", "r");
    if (link == NULL)
    {
        perror("open failed!");
        exit(-1);
    }
    char buffer[5];
    fscanf(link, "%s", buffer);
    printf("read from test.file.link is %s\n", buffer);
    //关闭文件
    fclose(link);
    return 0;
}